package com.dq.domain.message.oneself.info;

import com.dq.vo.baseVo.VO;
import com.dq.domain.message.oneself.InstructionMessage;
import com.dq.domain.message.oneself.Message;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * @author cf
 * @date 2019/11/22 0022 10:31:46
 */
@Data
@Entity
@ApiModel("指令消息回复")
public class InstructionMessageReturn extends Message{

    @ApiModelProperty("附件地址")
    @Column(columnDefinition = "text")
    public String annexUrl;
    @ApiModelProperty("图片地址")
    @Column(columnDefinition = "text")
    public String imageUrl;

    @ApiModelProperty("备注")
    public String remark;

    /**
     * 下级对上级指派的指令进行回复
     */
    @ApiModelProperty("上级指令")
    @ManyToOne
    public InstructionMessage instructionMessage;

    /**
     * 指令的下级才有值
     */
    @ApiModelProperty("状态,（no: 拒绝指令/ ok: 确认指令）")
    @Enumerated(EnumType.ORDINAL)
    @NotNull
    protected Status status;

    /**
     * 指令的下级才有值
     */
    @ApiModelProperty("boss状态")
    @Enumerated(EnumType.ORDINAL)
    protected BossStatus bossStatus;

    public enum Status{
        /**
         * 确认指令
         */
        ok("已完成"),
        /**
         * 拒绝指令
         */
        no("已拒绝"),
        begin("未操作")
        ;

        public String name;

        Status(String name){
            this.name = name;
        }
    }

    public enum BossStatus{
        adopt("通过"),
        noAdopt("未通过")
        ;

        public String name;

        BossStatus(String name){
            this.name = name;
        }
    }


    @Data
    @ApiModel("视图")
    public static class Vo implements VO {

        @ApiModelProperty("附件地址")
        public String annexUrl;
        @ApiModelProperty("图片地址")
        public String imageUrl;
        @ApiModelProperty("备注")
        public String remark;

    }

    @Override
    public VO toVO(boolean isRecursion) {
        Vo vo = new Vo();
        vo.annexUrl = this.annexUrl;
        vo.imageUrl = this.imageUrl;
        vo.remark = this.remark;

        return vo;
    }

}
